<?php

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Manager extends Authenticatable
{
    use Notifiable, HasApiTokens;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'user_id',
    ];

    /**
     * 获取店铺
     */
    public function mstore() {
        return $this->hasOne('App\Models\Store', 'store_id');
    }

    /**
     * 绑定的用户
     */
    public function user() {
        return $this->belongsTo('App\Models\User', 'user_id');
    }


    /**
     * 是否是管理员
     */
    public function isAdmin() {
        return $this->id === 1;
    }

}
